package com.acworks.acroute;

import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Hello world!
 *
 */
public class Main {

    final private static Logger LOG = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
        LOG.info("Starting AcRoute Calculator...");

        final long startTime = System.nanoTime();

        //TODO accept & parse input
        Integer[] ints = {
            2, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            3, 0, 0, 0, 1, 1
        };
        int width = 6;
        int height = 6;
        //TODO accept & parse input
//        Integer[] ints = {
//            2, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            0, 0, 0, 0, 0, 0, 0,
//            3, 0, 0, 0, 0, 1, 1
//        };
//        int width = 7;
//        int height = 8;
        List<Integer> inputInts = Arrays.asList(ints);

        Datacenter dc = DatacenterFactory.buildDatacenter(width, height, inputInts);

        RouteBuilder routeBuilder = new RouteBuilder(dc);

        final int validRouteCount = routeBuilder.computeValidRouteCount();

        final long durationMillis = (System.nanoTime() - startTime) / 1000000;

        //TODO change output format to
        //"Your program should write a single integer out to stdout: the number of possible ways to run the duct."

        LOG.info("found " + validRouteCount + " valid routes in " + durationMillis + " millis");
        System.out.println(validRouteCount + " in " + durationMillis + " millis");
    }
}
